package com.cssy.yd.logic.dao.impl;

import com.cssy.yd.logic.dao.LogicOtherOutwhItemDAO;
import com.cssy.yd.logic.entity.LogicOtherOutwhItemDO;
import com.plat.helper.SearchConditions;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2013-05-23
 */
public class LogicOtherOutwhItemDAOImpl extends SqlMapClientDaoSupport implements LogicOtherOutwhItemDAO {

    /**
     * 插入数据
     * @param logicOtherOutwhItemDO
     * @return 插入数据的主键
     */
    public String insertLogicOtherOutwhItemDO(LogicOtherOutwhItemDO logicOtherOutwhItemDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("LogicOtherOutwhItem.insert", logicOtherOutwhItemDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicOtherOutwhItemDO
     * @return 查出的记录数
     */
    public Integer countLogicOtherOutwhItemDOByExample(LogicOtherOutwhItemDO logicOtherOutwhItemDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicOtherOutwhItem.countByDOExample", logicOtherOutwhItemDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicOtherOutwhItemDO
     * @return 受影响的行数
     */
    public Integer updateLogicOtherOutwhItemDO(LogicOtherOutwhItemDO logicOtherOutwhItemDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("LogicOtherOutwhItem.update", logicOtherOutwhItemDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicOtherOutwhItemDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicOtherOutwhItemDO> findListByExample(LogicOtherOutwhItemDO logicOtherOutwhItemDO) throws DataAccessException {
        List<LogicOtherOutwhItemDO> list = getSqlMapClientTemplate().queryForList("LogicOtherOutwhItem.findListByDO", logicOtherOutwhItemDO);
        return list;
    }

    /**
     * 根据主键获取logicOtherOutwhItemDO
     * @param id
     * @return logicOtherOutwhItemDO
     */
    public LogicOtherOutwhItemDO findLogicOtherOutwhItemDOByPrimaryKey(String id) throws DataAccessException {
        LogicOtherOutwhItemDO logicOtherOutwhItemDO = (LogicOtherOutwhItemDO) getSqlMapClientTemplate().queryForObject("LogicOtherOutwhItem.findByPrimaryKey", id);
        return logicOtherOutwhItemDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicOtherOutwhItemDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicOtherOutwhItem.deleteByPrimaryKey", id);
        return rows;
    }

    @Override
    public List<LogicOtherOutwhItemDO> find(SearchConditions scs) throws DataAccessException{
		List<LogicOtherOutwhItemDO> list = getSqlMapClientTemplate().queryForList("LogicOtherOutwhItem_ex.find", scs);
   		   return list;
    }
    
	@Override
    public Integer count(SearchConditions scs) throws DataAccessException {		
		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicOtherOutwhItem_ex.count", scs);
  	      return count;
  	}
	
	@Override
	public List<LogicOtherOutwhItemDO> findByPid(String pid)
			throws DataAccessException {
		@SuppressWarnings("unchecked")
		List<LogicOtherOutwhItemDO> list = getSqlMapClientTemplate().queryForList("LogicOtherOutwhItem_ex.findByPid", pid);
		return list;
	}

	@Override
	public void deleteByPid(String pid) throws DataAccessException {
		getSqlMapClientTemplate().delete("LogicOtherOutwhItem_ex.deleteByPid",pid);
	}
}